package ai.people.platform.archives.controller;

import ai.people.core.nebula.entity.NebulaGraph;
import ai.people.netmon.framework.domain.archives.request.ArchivesAddAllRequest;
import ai.people.netmon.framework.domain.archives.request.ArchivesUpdateAllRequest;
import ai.people.netmon.framework.model.response.Result;
import ai.people.netmon.framework.utils.ResultUtil;
import ai.people.platform.archives.service.GraphAdminService;
import ai.people.platform.archives.service.GraphService;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 档案v2接口
 *
 * @author zhenglin
 * @date 2022/5/11
 */
@RefreshScope
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping("/v2")
public class ArchivesV2Controller {

    /**
     * 图服务
     */
    private final GraphService graphServiceImpl;

    /**
     * 保存档案+图
     *
     * @param all 所有
     * @return {@link Result}<{@link String}>
     * @throws Exception 异常
     */
    @PostMapping("/saveAll")
    public Result<String> saveAll(@Validated @RequestBody ArchivesAddAllRequest all) throws Exception {
        String archivesId = graphServiceImpl.saveAll(all);
        return ResultUtil.success(archivesId);
    }

    /**
     * 修改档案+图
     *
     * @param all 所有
     * @return {@link Result}<{@link Boolean}>
     * @throws Exception 异常
     */
    @PostMapping("/updateAll")
    public Result<Boolean> updateAll(@Validated @RequestBody ArchivesUpdateAllRequest all) throws Exception {
        graphServiceImpl.updateAll(all);
        return ResultUtil.success();
    }

}
